package hmmseg;


/**
 * Created by heqian on 17-7-12.
 */
public class Hemmseg {
    private final String libPath;
    private Object lock = new Object();

    private static native void init(String dicPath);

    private static native void save(String dicPath);

    private static native String showpos();

    private static native String show();

    private static native String parse(String text);

    private static native String add(String word, String pos, String other);

    public Hemmseg(String libPath) {
        synchronized (lock) {
            this.libPath = libPath;
            System.load(libPath + "/libhemmseg.so");
            init(libPath + "word.dic");
        }
    }

    public void Init(String dicPath) {
        synchronized (lock) {
            init(dicPath);
        }
    }

    public void Save(String dicPath) {
        synchronized (lock) {
            save(dicPath);
        }
    }


    public void Save() {
        synchronized (lock) {
            save(libPath + "word.dic");
        }
    }

    public String Showpos() {
        synchronized (lock) {
            return showpos();
        }
    }

    public String Show() {
        synchronized (lock) {
            return show();
        }
    }

    public String Parse(String text) {
        synchronized (lock) {
            return parse(text);
        }
    }

    public void Add(String word, EnumPos pos, String other) {
        synchronized (lock) {
            add(word, pos.name(), other);
        }
    }
}
